package com.example.validdemo.model;

import com.example.validdemo.validator.AgeGroupSequenceProvider;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 系统用户
 *
 * @author Bx_Hu
 */
@Data
@Accessors(chain = true)
@GroupSequenceProvider(AgeGroupSequenceProvider.class)
public class SysUserAgeVO implements Serializable {

    public interface Forbidden {
    }

    public interface Normal {
    }

    /**
     * 年龄 大于18岁,大于60岁
     */
    @ApiModelProperty(value = "年龄 大于18岁,大于60岁")
    @NotNull(message = "用户年龄必填")
    @Min(message = "用户年龄必须大于{value}岁",value = 18)
    @Max(message = "用户年龄必须小于{value}岁",value = 80)
    private Integer age;
    /**
     *
     */
    @ApiModelProperty(value = "状态  0：禁用   1：正常")
    @NotNull(message = "用户状态必选")
    @AssertTrue(message = "用户年龄大于60岁时,用户状态必须为禁用", groups = {Forbidden.class})
    @AssertFalse(message = "用户年龄小于60岁时,用户状态必须为正常", groups = {Normal.class})
    private Boolean status;


    private static final long serialVersionUID = 1L;
}
